#include<iostream>
#include<unistd.h>
#include<signal.h>

void handler(int sig)
{
    std::cout<<"get sig = "<<sig<<std::endl;
    sleep(100);
    exit(1);
}
int main()
{
    struct sigaction act,oldact;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);
    act.sa_handler = handler;
     //如果你还想处理2号，同时对其他（下面以3号为例子）信号也进行屏蔽
    sigaddset(&act.sa_mask,3);

    sigaction(SIGINT,&act,&oldact);
    while(true)
    {
        std::cout<<"i am process,pid = "<<getpid()<<std::endl;
        sleep(1);
    }
    return 0;
}